n, m = input().split()
n = int(n)
m = int(m)
dormitories = input().split()
roomIndices = [0] + [None] * (n - 1)
roomIndex = 0
for i in range(n-1):
roomIndex += int(dormitories[i])
roomIndices[i + 1] = roomIndex
def binSearch(number, start, end):
if start == end:
return str(start + 1) + " " + str(number - roomIndices[start])
if number > roomIndices[(start + end + 1) // 2]:
return binSearch(number, (start + end + 1) // 2, end)
return binSearch(number, start, (start + end) // 2)
for i in input().split():
print(binSearch(int(i), 0, n - 1))
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
// file I/O
/*ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs*/
/* ------------------------------------ */
template <typename T>
ostream& operator <<(ostream& output, const vector<T>& data) {
for (const T& x : data)
output << x <<" ";
return output;
}
template<typename T>
istream& operator>>(istream& input,vector<T>& data) {
for (auto& item : data)
input >> item;
return input;
}
/* ------------------------------------ */
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define SUM(v) accumulate(all(v), 0LL)
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define endl "\n"
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int MAX = 2e5+5;
/////////////////////////////////////////////
void solve() {
ll n,m;
cin>>n>>m;
vector<ll> v(n+1);
for(ll i=1; i<=n; ++i) {
ll x; cin>>x;
v[i] = x + v[i-1];
}
while(m--) {
ll x; cin>>x;
auto it = lower_bound(all(v),x);
cout<<it - v.begin()<<" ";
--it;
cout<<x - *it<<endl;
}
return;
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);
ll tc=1;
// cin>>tc;
for(ll i=1; i<=tc; ++i) {
solve();
}
return 0;
}
67A - Partial Teacher | 116A - Tram |
1472B - Fair Division | 1281C - Cut and Paste |
141A - Amusing Joke | 112A - Petya and Strings |
677A - Vanya and Fence | 1621A - Stable Arrangement of Rooks |
472A - Design Tutorial Learn from Math | 1368A - C+= |
450A - Jzzhu and Children | 546A - Soldier and Bananas |
32B - Borze | 1651B - Prove Him Wrong |
381A - Sereja and Dima | 41A - Translation |
1559A - Mocha and Math | 832A - Sasha and Sticks |
292B - Network Topology | 1339A - Filling Diamonds |
910A - The Way to Home | 617A - Elephant |
48A - Rock-paper-scissors | 294A - Shaass and Oskols |
1213A - Chips Moving | 490A - Team Olympiad |
233A - Perfect Permutation | 1360A - Minimal Square |
467A - George and Accommodation | 893C - Rumor |